package com.pluginsacceptor.plugin.formula.datetime;

import static org.junit.Assert.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.pluginsacceptor.plugin.formula.datetime.DateTime;
import com.pluginsacceptor.plugin.formula.datetime.DateTimeAPI;

public class DateTimeTest {

	DateTimeAPI dateTime;
	SimpleDateFormat sdf ;
	Date date;

	
		
	
	@Before
	public void setUp() throws Exception {
		dateTime = new DateTime();
	}

	@After
	public void tearDown() throws Exception {
		dateTime = null;
	}

	@Test
	public void testGetMonth() throws ParseException {
		sdf = new SimpleDateFormat("dd-MM-yyyy");
		String dateInput="12-12-2012";
		date = sdf.parse(dateInput);
		String apiTest=dateTime.getMonth(date);
		assertEquals("Decembre", apiTest);
		
		
	}

	@Test
	public void testGetMonthValue() throws ParseException {
		sdf = new SimpleDateFormat("dd-MM-yyyy");
		String dateInput="12-12-2012";
		date = sdf.parse(dateInput);
		int apiTest=dateTime.getMonthValue(date);
		assertEquals(12, apiTest);
	}

	@Test
	public void testGetDayOfTheMonth() throws ParseException {
		sdf = new SimpleDateFormat("dd-MM-yyyy");
		String dateInput="12-12-2012";
		date = sdf.parse(dateInput);
		int apiTest=dateTime.getDayOfTheMonth(date);
		assertEquals(12, apiTest);
	}

	@Test
	public void testGetYear() throws ParseException {
		sdf = new SimpleDateFormat("dd-MM-yyyy");
		String dateInput="12-12-2012";
		date = sdf.parse(dateInput);
		int apiTest=dateTime.getYear(date);
		assertEquals(2012, apiTest);
	}

	@Test
	public void testGetWeekDay() throws ParseException {
		sdf = new SimpleDateFormat("dd-MM-yyyy");
		String dateInput="12-12-2012";
		date = sdf.parse(dateInput);
		String apiTest=dateTime.getWeekDay(date);
		assertEquals("Mercredi", apiTest);
	}

	@Test
	public void testGetTheDayOfTheYear() throws ParseException {
		sdf = new SimpleDateFormat("dd-MM-yyyy");
		String dateInput="12-12-2012";
		date = sdf.parse(dateInput);
		int apiTest=dateTime.getTheDayOfTheYear(date);
		assertEquals(347, apiTest);
	}


	@Test
	public void testGetMinute() {
		//fail("Not yet implemented");
	}

	@Test
	public void testGetHour24() {
		//fail("Not yet implemented");
	}

	@Test
	public void testGetHour12() {
		//fail("Not yet implemented");
	}

	@Test
	public void testGetSecond() {
		//fail("Not yet implemented");
	}

}
